package com.rtmart.image.utils;

import lombok.Getter;

@Getter
public class ResponseBuilder {
    public static enum Code{
        //请求成功
        SUCCESS(0, "请求成功"),
        //请求失败
        ERROR(9999, "请求失败");

        private String message;
        private Integer index;

        private Code(Integer index, String message) {
            this.message = message;
            this.index = index;
        }
    }

    private Integer code;
    private String message;
    private Object data;

    public ResponseBuilder(Code code, Object data) {
        this.code = code.index;
        this.message = code.message;
        this.data = data;
    }

    public static ResponseBuilder build(Code code, Object data) {
        return new ResponseBuilder(code, data);
    }

    public static ResponseBuilder build(Code code) {
        return new ResponseBuilder(code, null);
    }

}
